package com.bdqn.t296.noso;

import com.bdqn.t296.noso.entity.User;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

@SpringBootTest
@RunWith(SpringRunner.class)
public class RedisTemplateTester {
    @Resource
    private StringRedisTemplate stringRedisTemplate; //操作字符串数据
    @Resource
    private RedisTemplate redisTemplate; //操作其他数据类型

    @Test
    public void testString() {
        User user = new User();
        user.setLoginname("czkt");
        ValueOperations<String, User> operations = redisTemplate.opsForValue();
        operations.set("ktjiaoyu.crm.user.czkt", user);
        User u = operations.get("ktjiaoyu.crm.user.czkt");
        System.out.println("user.usrName: " + u.getLoginname());
    }
}
